#ifndef EVENT_H
#define EVENT_H
#include <iostream>
#include "Utils.H"
#include <vector>

struct EnumNamePair 
{
	int id;
	const char *name;
};



enum EventId
{

	/*broadcast messages*/
	eAll_FIRST_HOUSE=0,  /* First House is built by player Y */
	eALL_UPDATE,       /* Update message from table */
	/*msg between one player and Table*/
	et_GIVE_FLOORS,    /* Give me your house rank. possible rank=9,10,J,Q,K*/
	et_FORCED_BUILD,   /* Now you build as per choosen rank( i.e 9,10,..13 )*/
	et_ADD_MORE,       /* Add more cards Form loose cards to house*/
	et_YOUR_TURN,	   /* Its your turn boss....*/	
	et_TAKE_FROM_DECK, /* Take these 4 cards */
	et_PICK_MORE,      /* Pick more loose cards or House*/

	ep_HOUSE_INFO=100, /* I am going to make 9(9,10,J,Q,K ) at the beginning of the game*/	
	ep_LOOSE_THROW,    /* I am throwing loose card */
	ep_HOUSE_BUILD,    /* I am building house */
	ep_HOUSE_LOOSE_ADD,/* Adding some loose cards without using my cards into House */
	ep_HOUSE_ADD,	   /* Adding my card and some(none) from loose cards */	
	ep_HOUSE_ADDFLOORS,/* Increasing un-plastered house floors. e.g. form J to K.*/
	ep_PICK,           /* Taking these loose cards */
	ep_DEAL_AGAIN      /* Boss!! you did not give me one of 9,10,J,Q,K. Please deal again*/
};

class Card;
class Event
{
	private:
		int mWhatEvent;
		UINT16 mSender;
		Card *mSentCard;
		UINT16 mRank;
		std::vector<Card*> mCardList;
	public:
	
		friend std::ostream &operator<<(std::ostream &Out, Event &Evt) ;
		static const EnumNamePair EventIdToNameTable[];
		void Dump()
		{
			std::cout << "eId = " << mWhatEvent << *this <<", Sender=" << mSentCard << ", mRank=" << mRank << ", mSentCard" ;
			return;

}
		int  What() { return mWhatEvent; }
		UINT16 GetSenderId() { return mSender;}
		UINT16 GetRank()     { return mRank; }
		Card* GetThrownCard()  { return mSentCard; }
		std::vector<Card*> *GetCardList() { return &mCardList; }

		Event( int eventId, UINT16 senderId=0, Card *senderCard=NULL, UINT16 rank=0, std::vector<Card*> *list=NULL )
			: mWhatEvent( eventId ),
			mSender   ( senderId ),
			mSentCard ( senderCard ),
			mRank     ( rank )
	{
		if ( list == NULL ) return;
		int num=list->size();
		while ( num > 0 )
		{
			num = num-1;
			mCardList.push_back( (*list)[num] );
		}
	}; 
		Event( Event *e ) { mWhatEvent = e->mWhatEvent; mCardList=e->mCardList; }
};
#endif //EVENT_H
